package com.jspx.talk.event;

import com.jspx.boot.environment.Environment;
import com.jspx.txweb.table.TalkMessage;
import com.jspx.talk.TalkListener;
import com.jspx.talk.core.TalkLogicService;

import java.util.List;

/**
 * Created by chenyuan on 2015-8-11.
 *
 */
public  abstract class TalkEventListener implements TalkListener {
    static public final String SUCCESS = TalkLogicService.SUCCESS; //无问题
    static public final String ERROR = TalkLogicService.ERROR; //发生错误

    private String name;

    @Override
    public String getName() {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String delete(List<TalkMessage> talkMessageList)
    {
        if (talkMessageList==null||talkMessageList.isEmpty())
        {
            getFieldErrors().put(Environment.warningInfo,"无数据删除");
            return ERROR;
        }
        TalkMessage[] talkMessage = new TalkMessage[talkMessageList.size()];
        talkMessage = talkMessageList.toArray(talkMessage);
        return delete(talkMessage);
    }

}
